package com.iot08.push.mqtt.handle;

import com.iot08.push.mqtt.conf.MqttConfig;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

/**
 * @version 1.0
 * @Description: MQTT生产者消息发送接口
 * @author: Rock
 * @time: 2020/9/25 9:12
 */
@Component
@MessagingGateway(defaultRequestChannel = MqttConfig.CHANNEL_NAME_OUT)
public interface IMqttSender {

    /**
     * 发送信息到MQTT服务器
     *
     * @param [data]
     * @time: 2020/9/25 9:12
     * @author: Rock
     * @version 1.0
     */
    void sendToMqtt(String data);

    /**
     * 发送信息到MQTT服务器
     *
     * @param [topic, payload]
     * @time: 2020/9/25 9:12
     * @author: Rock
     * @version 1.0
     */
    void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, String payload);

    /**
     * 发送信息到MQTT服务器
     * 0 至多一次，数据可能丢失
     * 1 至少一次，数据可能重复
     * 2 只有一次，且仅有一次，最耗性能
     *
     * @param [topic, qos, payload]
     * @time: 2020/9/25 9:13
     * @author: Rock
     * @version 1.0
     */
    void sendToMqtt(@Header(MqttHeaders.TOPIC) String topic, @Header(MqttHeaders.QOS) int qos, String payload);
}
